<%--
 *  File:   contactRelationPopWindow.jsp
 *  Date		  Author		  Changes
 *  2009-11-11	  awesomewang		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
	//init param
  	String privilegeCode = "All";
    String strModuleName = "COM";
  	String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<iframe name="reloadHandler" style="display:none"></iframe>
<html>
<head>
<title>contactRelationPopWindow</title>
<PageFlow:CheckPageFlow pageName="p_contactrelation"/>
<%@ include file="/inc/AlertError.inc" %>
<%
  Vector details = (Vector)pageContext.getAttribute("details");
  if(details == null) details = new Vector();
   
  Integer usrid = (Integer)pageContext.getAttribute("usrid");
  if(usrid == null) usrid = new Integer(0);

%>

<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<%
	HashMap Cuserinfo = (HashMap)session.getAttribute("userinfo");
   	if (Cuserinfo==null){
   		Cuserinfo = new HashMap();
   	}
   	String strIsFromHomepage1 = "N";
   	if (Cuserinfo.get("isFromHomepage1")!=null ){
   		strIsFromHomepage1 = (String)Cuserinfo.get("isFromHomepage1");
    }   
   	
   	String isview=(String)request.getParameter("isview");
  	if(isview == null)
  	{
  		isview = "";
  	}
  	HashMap usrhash = (HashMap)pageContext.getAttribute("usrhash");
%>
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript">
function page_setItem(itemid)
{
    cform.itemid.value='';
    cform.itemname.value='';
    cform.umcode.value='';
    cform.umname.value='';
    if(itemid!=null)
    {
        cform.itemid.value = itemid;
        cform.itemcode.value = '';
    }
    page_handleRequest('<%=contextPath%>',cform);
}
function page_handleResponse()
{
    cform.itemid.value = getResponseData("itemid");
    cform.itemcode.value = getResponseData("itemcode");
    cform.itemname.value = getResponseData("itemname");
    cform.umcode.value = getResponseData("umcode");
    cform.umname.value = getResponseData("umname");
}
function page_add(){
      //alert(document.cform.childusrid.value);
    if(!checkALLElems(document.getElementById("newdetail"))) return;    
    if ((document.cform.employeename.value==null)||(document.cform.employeename.value.length <= 0)||(document.cform.employeename.value=="null")){
    	alert("<%=message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_SalesRepName"))%>");
        return;
    } 
    cform.actionname.value = "add";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_delete() 
{
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_save()
{
    if(!checkALLElems(document.getElementById("olddetail"))) return;
    cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function set_repNameByPopWindow(id,code,name){
	document.cform.employeecode.value=code;
	document.cform.employeename.value=name;
	document.cform.childusrid.value=id;
}

function setNamebycode(code){
	var  codevalue = code.value;
	var  datahandler = new  DataHandler() ;
	
	datahandler.add_params("employeecode" , codevalue,"string") ;
  	datahandler.add_params("languagecode" , 'cn',"string") ;
  	
  	datahandler.getResultFromHashMap("info" ,"employeename" ,"document.cform.employeename");
  	datahandler.getResultFromHashMap("info" ,"productbrandid" ,"document.cform.productbrandid");
  	datahandler.add_job("j_getnameforcode") ;
  	
    datahandler.runDataHandler ();
}
</script>
<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher" >
  <input type="hidden" name="pagename" value="p_contactrelation">
  <input type="hidden" name="actionname">
  <input type="hidden" name="isview" value="<%=request.getParameter("isview") %>">
  <input type="hidden" name="schema" value="v_zylusrofbusiness">
  <input type="hidden" name="usrid" value="<%=usrid %>">	
  <input type="hidden" name="numrows" value="<%= details.size() %>">
<table width="100%" cellspacing="0" border="0" cellpadding="0">
	<tr>
		<td>
		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0">
		<tr class="deepblue-left"> 
          	<td width="5%" class="deepblue-left">&nbsp;</td>
          	<td width="30%" class="title_center">&nbsp;<%= label.getLabelName("L_SalesRepCode") %></td>
	  		<td class="title_center">&nbsp;<%= label.getLabelName("L_SalesRepName") %></td>
        </tr>
	    <span id="olddetail" >
       	<logic:iterate id="onerow" collection="<%= details %>" indexId="idx">
               <%
               HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
               %>
           <tr>
         	<td width="30">
				<custom:checkbox property="zylusrrelationid" name="onerow" changedName="deleteids" styleClass="normalradio" />
         	</td>
	        <td><custom:write name="onerow" property="employeecode"nbsp="true" /></td>
	        <td><custom:write name="onerow" property="employeename" nbsp="true"/></td>
    	</tr>
       	<tr>
         	<td style="display:none"><imput type="hidden"  name="childusrid<%= idx %>"  value="<%=JspHelper.filterNull( tempMap.get("childusrid") )%>" ></td>
        </tr>
        </logic:iterate>
		</span>
		<%
		if(!("1".equals(isview))){
		%>
		<span id="newdetail" >
       	<tr >
         	<td>&nbsp;</td>
         	<td>
           		<!--<custom:text name="newdetail" property="employeecode" style="width:80%" onchange="javascript:setNamebycode(this);"/>-->
           		<custom:text name="newdetail" property="employeecode" style="width:80%" />
           		<a onclick='window.open("ContactAllPopWindow.jsp?<%= OvalTools.randomURL() %>&newuserid=<%=usrid %>", "newwindow", "height=400, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes")'>
                    		<custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
            </td>
            <td><custom:text name="newdetail" property="employeename" readonly="true" /><custom:hidden property="childusrid" /></td>
       	</tr>
		</span>
         <%} %> 
		</table>
		<%//--------------------------------------  page operation button --%>
		<%
		if(!("1".equals(isview))){
		%>
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
			<tr>
				<td class="td_center"><a onclick="javascript:page_add();"><custom:button type="1" label="L_Save" imgsrc="finish.gif" border="0" style="width:60" /></a>
				<a onclick="javascript:page_delete();"><custom:button type="1" label="L_Delete" imgsrc="finish.gif" border="0" style="width:60" /></a></td>
			</tr>
		</table>
		<%  
		} %>
		</td>
	</tr>
</table>

</form>
</body>
</html>